
import { _decorator, Component, Node } from 'cc';
import { BulletOrigin } from './BulletOrigin';
import { tasteMainGun_config } from '../../manager/AppControll';
import { MainGun } from '../gun/MainGun';
import { MonsterOrigin } from '../monster/MonsterOrigin';
import { DataHelper } from '../../system/DataHelper';
import { Tools } from '../../tools/Tools';
import { BulletManager } from './BulletManager';
const { ccclass, property } = _decorator;

@ccclass('BulletDouble')
export class BulletDouble extends BulletOrigin {
    private mTasteConfig: tasteMainGun_config = null;
    private mTarget: Node = null;
    InitConfig(config: tasteMainGun_config, target: Node) {
        this.mTasteConfig = config;
        this.mTarget = target;
    }

    MoveFinish() {
        if (!this.node) return
        if (!this.mTarget) {
            return;
        }
        if (this.mTarget.components && !this.mTarget.getComponent(MonsterOrigin)) {
            BulletManager.Instance<BulletManager>().doubleBulletPool.put(this.node);
            return;
        }
        if (this.mTarget) {

            let atk = DataHelper.GetAttack().attributeNum;
            let chtRate = DataHelper.GetCriticalHitRate().attributeNum;
            let chtdmg = DataHelper.GetCriticalHitDamage().attributeNum;
            let damageBoost = DataHelper.GetDamageBoost().attributeNum;
            let skinDmg = DataHelper.GetSkinBuffDmg();
            atk = atk + atk * (skinDmg - 1);
            let dmg = Tools.CalculateDamage(atk, chtRate, chtdmg, damageBoost, 0);
            this.mTarget.getComponent(MonsterOrigin).Attacked(dmg);
            this.mTarget.getComponent(MonsterOrigin).Attacked(dmg);



        }
        BulletManager.Instance<BulletManager>().doubleBulletPool.put(this.node);
    }

    start() {
    }

}
